import { PageParams } from '@/api/model/pageParams';
import { request } from '@/utils/request';

const pageMaterialsApi = async (params: PageParams) => {
  return request.post({
    url: '/medicinal/page',
    data: params,
  });
};

const getAllEfficacyApi = async () => {
  return request.get({
    url: '/medicinal/efficacy',
  });
};

const insertMaterialsApi = async (data: any) => {
  return request.post({
    url: '/medicinal/insert',
    data,
  });
};

const updateMaterialsApi = async (data: any) => {
  return request.post({
    url: '/medicinal/update',
    data,
  });
};

const deleteMaterialsApi = async (id: string) => {
  return request.get({
    url: `/medicinal/delete/${id}`,
  });
};

const deleteEfficacyApi = async (id: number, efficacyId: number) => {
  return request.get({
    url: `/medicinal/deleteEfficacy/${id}/${efficacyId}`,
  });
};

const updateEfficacyApi = async (data: any) => {
  return request.post({
    url: '/medicinal/updateEfficacy',
    data,
  });
};

// 添加图集
const addPicturesApi = async (data: any) => {
  return request.post({
    url: '/medicinal/addPictures',
    data,
  });
};

// 图集列表
const getPicturesApi = async (id: number) => {
  return request.get({
    url: `/medicinal/pictures/${id}`,
  });
};

/**
 * 删除图集
 * @param picId
 */
const deletePictureApi = async (picId: number) => {
  return request.get({
    url: `/medicinal/deletePicture/${picId}`,
  });
};

/**
 * 获取所有药品
 */
const getAllMaterialsApi = () =>
  request.get({
    url: '/medicinal/all',
  });

/**
 * 添加/修改药品禁忌
 */
const addOrUpdateTabooApi = (data: any) => {
  return request.post({
    url: '/medicinal/addTaboo',
    data,
  });
};
export {
  addOrUpdateTabooApi,
  addPicturesApi,
  deleteEfficacyApi,
  deleteMaterialsApi,
  deletePictureApi,
  getAllEfficacyApi,
  getAllMaterialsApi,
  getPicturesApi,
  insertMaterialsApi,
  pageMaterialsApi,
  updateEfficacyApi,
  updateMaterialsApi,
};
